<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text">
<input type="button" value="平方" onclick="f()">
<input type="button" value="求和" onclick="f1()">

<div>结果：</div>

<script>
    let d = document.querySelector("div");
    let i = document.querySelector("input")
    function f() {
        if(isNaN(i.value) ){
            d.innerText = "输入有误";
            return;
        }else {
            d.innerText = "结果："+i.value * i.value;
        }
    }
    function f1() {
        if(isNaN(i.value) ){
            d.innerText = "输入有误";
            return;
        }else {
            d.innerText = "结果："+ (parseFloat(i.value) + parseFloat(i.value));
        }
    }
</script>
</body>
</html>